package com.duowei.diandan.fragment;

import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;

import com.duowei.diandan.db.AppDatabase;
import com.duowei.diandan.event.ToastEvent;

import org.greenrobot.eventbus.EventBus;

public class BaseFragment extends Fragment {

    private AppDatabase mDb;
    private Handler mHandler = new Handler();

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mDb = AppDatabase.getDatabase();
    }

    public AppDatabase getDb() {
        return mDb;
    }

    public Handler getHandler() {
        return mHandler;
    }

    public void showToast(String toast, boolean animated) {
        EventBus.getDefault().post(new ToastEvent(toast, animated));
    }
}
